﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using WindowsPhoneApp;

namespace WindowsPhoneAppHost
{
    public partial class NavigationBar : UserControl, INotifyPropertyChanged
    {
        //buttonClick
        string buttonClick;
        public NavigationBar()
        {
            InitializeComponent();
//            this.FindName("")
//            this.
        }
        public Action Clicked { get; set; }
//        Action 
        public event PropertyChangedEventHandler PropertyChanged;
        public event EventHandler OkClick;
        public event EventHandler CancelClick;
//        /*
        [Description("Test text displayed in the textbox"), Category("Data")]
        public string ButtonClick
        {
            //            get { return button1.Click; }
            get { return this.buttonClick; }
//            set { button1.Click += new System.EventHandler(value); }
            set
            {
                this.buttonClick = value;
                //button1.Click += this.button1_Click;
            }
//            get { return textBlock1.Text; }
//            set { textBlock1.Text = value; }
//            this.
        }
//         */

        [Description("Test text displayed in the textbox"), Category("Data")]
        public string TitleText
        {
            get { return textBlock1.Text; }
            set { textBlock1.Text = value; }
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //TabNavigation

            var page = (Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as Microsoft.Phone.Controls.PhoneApplicationPage;
            page.NavigationService.GoBack();
            //NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            //NavigationService.
        }
        /*
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //Application.Current.RootVisual;
            var page = (Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as Microsoft.Phone.Controls.PhoneApplicationPage;
            //OaMainPage page = (OaMainPage)(Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as Microsoft.Phone.Controls.PhoneApplicationPage;
            var type = page.GetType();
            //MethodInfo[] myMethodInfo = type.GetMethods();
            //MethodInfo methodInfo = type.GetMethod("button1_Click_1", BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo methodInfo = type.GetMethod(ButtonClick);
            //methodInfo = type.GetMethod("ShowAlert");
            //MethodInfo methodInfo = page.GetType().GetMethod(ButtonClick);
            methodInfo.Invoke(page, new object[] { sender, e });
//            StackPanel stackPanel = (StackPanel) this.Parent;
            //stackPanel.GetValue(stackPanel.);
//            stackPanel.
//            OaMainPage page =  (OaMainPage)this.Parent;
//            page.ShowAlert();
        }
         */

            
    }
}
